using Backoffice.Domain.Entities;
using Backoffice.Domain.Entities.App;

namespace BackOffice.Domain.Entities.App;

public class AppFileAcl : EntityBase
{
    public Guid FileId { get; private set; }
    public Guid UserId { get; private set; }
    public FileAccess Access { get; private set; }

    /* 导航属性 */
    public virtual AppFile File { get; private set; } = null!;

    private AppFileAcl() { }

    public AppFileAcl(Guid fileId, Guid userId, FileAccess access)
    {
        FileId = fileId;
        UserId = userId;
        Access = access;
    }

    public void UpdateAccess(FileAccess newAccess) => Access = newAccess;
}

[Flags]
public enum FileAccess
{
    None   = 0,
    Read   = 1,
    Write  = 2,
    Delete = 4,
    All    = Read | Write | Delete
}